#include <iostream>
// 装饰器模式

// 组件接口
class Component{
public:
    virtual ~Component() = default;
    virtual void operation() = 0;
};


// 具体组件
class ConcreteComponent : public Component{
public:
    void operation() override{
        std::cout << "ConcreteComponent operation" << std::endl;
    }
};  

// 装饰器基类
class Decorator : public Component{
protected:
    Component* component;
public:
    Decorator(Component* component) : component(component){}
    void operation() override{
        if(component){
            component->operation();
        }
    }
};

// 具体装饰器
class ConcreteDecoratorA : public Decorator{
public:
    ConcreteDecoratorA(Component* component) : Decorator(component){}
    void operation() override{
        Decorator::operation();
        std::cout << "ConcreteDecoratorA operation" << std::endl;
    }
private:
    void addedBehavior(){
        std::cout << "ConcreteDecoratorA added behavior" << std::endl;
    }
};


